var app = getApp()
Page({
  data: {
    isLogin:null,
    userInfo:null,
    studentID:"",
    name:""
  },

  onLoad: function (options) {
    this.setData({ isLogin: app.globalData.isLogin, userInfo: app.globalData.userInfo, studentID:app.globalData.studentID});
    console.log(this.data.studentID)
  },

  onShow:function(){

  },


  //授权
  login: function (e) {
    var isa = e.detail.errMsg;
    if (isa == "getUserInfo:ok") {
      wx.showToast({
        title: '正在授权',
        icon: 'loading'
      });
      this.setData({ isLogin: true, userInfo: e.detail.userInfo});
      wx.setStorageSync("userInfo", e.detail.userInfo);
      app.globalData.userInfo = e.detail.userInfo;
      app.globalData.isLogin = true;
    } else {
      wx.showToast({
        title: '请授权',
        icon: 'none'
      })
    }
    console.log(e)
  },
  //个人资料
  info:function(){
    wx.navigateTo({
      url: '/pages/mine/minemessage/minemessage',
    })
  },
  shouquan:function(){
    var student = wx.getStorageSync("student")
    var stuid = student.studentID
    wx.navigateTo({
      url: '/pages/provisional/pro-message/pro-message?allID='+stuid,
    })
    wx.showToast({
      title: '加载成功',
      icon: 'loading',
      mask:true,
      duration: 2000,
      success:function(){
        setTimeout(function () {
        }, 1000) 
      }
    })

  },
  //进出记录
  address: function () {
    wx.navigateTo({
      url: './address/address',
    })
    
  },
  out:function(){
    wx.clearStorageSync();
      wx.redirectTo({
        url: '/pages/first/first',
      })
  }
})